package com.example.hydrogengenerator.model

import androidx.lifecycle.MutableLiveData
import com.example.hydrogengenerator.bean.CacheUtil
import me.hgj.jetpackmvvm.base.viewmodel.BaseViewModel

class FactoryModel : BaseViewModel() {
    val factorySettingBean = MutableLiveData(CacheUtil.geFactorySetting())

    fun setFunction(i: Int) {
        factorySettingBean.value?.curFunction = i
        factorySettingBean.value = factorySettingBean.value
    }

    fun setLanguage(i: Int) {
        factorySettingBean.value?.language = i
        factorySettingBean.value = factorySettingBean.value
    }

    fun clear() {
        factorySettingBean.value?.hours = 0
        factorySettingBean.value = factorySettingBean.value
    }

    fun save() {
        CacheUtil.setFactorySetting(factorySettingBean.value)
    }
}